package UnitTests;

import java.util.ArrayList;
import java.util.Collection;

import Backwards.DBBackward;
import DomainLayer.AbstractEntity;
import DomainLayer.CommentaryEntity;
import DomainLayer.MovieEntity;
import DomainLayer.ProfitValueObject;
import DomainLayer.UserEntity;
import DomainLayer.UserStateValueObject;
import Helpers.ApplicationLogger;

public class CrudTests {

	public static void main(String[] args) {
		// ProfitValueObject p = new ProfitValueObject(new ProfitValueObject(),
		// 0,
		// 1d, 2d, 3d, 4d, 5d, 6d);
		// System.out.println("hello");

		// ------------------------------test of select
		// DBBackward dbb = new DBBackward();
		// UserEntity user = new UserEntity();
		// DBBackward.TableCRUD cCRUD = dbb.new TableCRUD(user);
		// Collection<AbstractEntity> result = cCRUD
		// .Select("select * from USER_TABLE where id = 16");
		// if (result.isEmpty() == false) {
		// user = (UserEntity) result.iterator().next();
		// System.out.println("User ID: " + user.getId());
		// System.out.println("User Login: " + user.getUserInfo().getLogin());
		// System.out.println("User Password: "
		// + user.getUserInfo().getPassword());
		// System.out
		// .println("User Gender: " + user.getUserInfo().getGender());
		//
		// }

		// -------Test-of-movie-request----------------------------------
		// Collection<AbstractEntity> collectionOfMov = new
		// ArrayList<AbstractEntity>();
		// MovieEntity movie = new MovieEntity();
		// DBBackward dbb = new DBBackward();
		// DBBackward.TableCRUD cCRUD = dbb.new TableCRUD(movie);
		// collectionOfMov = cCRUD.Select("select * from movie_table");
		// System.out.println(collectionOfMov.size());
		//
		// for (AbstractEntity m : collectionOfMov) {
		// System.out.println("----ID-" + ((MovieEntity) m).getId()
		// + "--------------");
		// System.out.println(((MovieEntity) m).getCover());
		// System.out.println(((MovieEntity) m).getMovieDescription());
		// System.out.println(((MovieEntity) m).getName());
		// System.out.println(((MovieEntity) m).getRating());
		// System.out.println(((MovieEntity) m).getRatingIMDB());
		// System.out.println(((MovieEntity) m).getActors());
		// System.out.println("commentaries:");
		// for (CommentaryEntity c : ((MovieEntity) m).getCommentaries()) {
		// System.out.println(c.getId());
		// System.out.println(c.getText());
		// System.out.println("+PARENT+");
		// if (c.getParent() != null)
		// System.out.println(c.getParent().getId());
		// System.out.println("+USER+");
		// System.out.println(c.getUser().getId());
		// System.out.println(c.getUser().getUserInfo().getLogin());
		// System.out.println(c.getUser().getUserInfo().getGender());
		// System.out.println(c.getUser().getUserState());
		// System.out.println("+++++++++++++++");
		// }
		// // System.out.println(((MovieEntity) m).getCommentaries());
		// System.out.println(((MovieEntity) m).getGenre());
		// System.out.println(((MovieEntity) m).getId());
		// System.out
		// .println(((MovieEntity) m).getProfit().getProfitFromDVD());
		// System.out.println(((MovieEntity) m).getProfit().getProfitFromTV());
		// System.out.println(((MovieEntity) m).getProfit()
		// .getProfitInEurope());
		// System.out.println(((MovieEntity) m).getProfit()
		// .getProfitInOtherCountries());
		// System.out.println(((MovieEntity) m).getProfit()
		// .getProfitInRussia());
		// System.out.println(((MovieEntity) m).getProfit().getProfitInUSA());
		// System.out.println(((MovieEntity) m).getProfit().getTotalProfit());
		// System.out.println(((MovieEntity) m).getRatingMPAA());
		// }

		// System.err.println(((MovieEntity) ((ArrayList)
		// collectionOfMov).get(0))
		// .getCommentaries().get(1).getParent().getId());

		// ----------------------------test of update (movie)
		// DBBackward dbb = new DBBackward();
		// DBBackward.TableCRUD cCRUD = dbb.new TableCRUD(new MovieEntity());
		// Collection<AbstractEntity> collectionOfMov = new
		// ArrayList<AbstractEntity>();
		// collectionOfMov = cCRUD.Select("select * from movie_table");
		//
		// System.out.println("Old Movie Name: "
		// + ((MovieEntity) ((ArrayList) collectionOfMov).get(0))
		// .getName());
		// ((MovieEntity) ((ArrayList) collectionOfMov).get(0)).setName("LOL!");
		//
		// DBBackward.TableCRUD crud = dbb.new TableCRUD(
		// ((ArrayList) collectionOfMov).get(0));
		// crud.Update();
		//
		// Collection<AbstractEntity> result = crud
		// .Select("select * from Movie_Table where id = 40");
		// MovieEntity movie = null;
		// if (result.isEmpty() == false) {
		// movie = (MovieEntity) result.iterator().next();
		// System.out.println("New Movie Name: " + movie.getName());
		// }

		// --------------------------test of update (user)
		// ----------------User-update_test-----------------------
		// DBBackward dbb = new DBBackward();
		//
		// DBBackward.TableCRUD crud = dbb.new TableCRUD(new UserEntity());
		//
		// Collection<AbstractEntity> collectionOfUser = new
		// ArrayList<AbstractEntity>();
		// collectionOfUser = crud.Select("select * from user_table");
		//
		// UserStateValueObject oldUserState = ((UserEntity) ((ArrayList)
		// collectionOfUser)
		// .get(0)).getUserState();
		// UserStateValueObject newUserState = new UserStateValueObject(
		// oldUserState, null, null, null, "1.2.3.4");
		//
		// ((UserEntity) ((ArrayList) collectionOfUser).get(0))
		// .setUserState(newUserState);
		//
		// crud = dbb.new TableCRUD(
		// ((UserEntity) ((ArrayList) collectionOfUser).get(0)));
		// crud.Update();

		// -------test-of-select-+-insert---------------
		// Collection<AbstractEntity> collectionOfMov = new
		// ArrayList<AbstractEntity>();
		// MovieEntity movie = new MovieEntity();
		// DBBackward dbb = new DBBackward();
		// DBBackward.TableCRUD cCRUD = dbb.new TableCRUD(movie);
		// collectionOfMov = cCRUD.Select("select * from movie_table");
		//
		// try {
		// MovieEntity m = (MovieEntity) ((ArrayList) collectionOfMov).get(0);
		// m.setProfit(new ProfitValueObject(m.getProfit(), 0, 1d, 2d, 3d, 44d,
		// 5d, 6d));
		//
		// DBBackward.TableCRUD crud = dbb.new TableCRUD(m);
		// crud.Create();
		// } catch (Exception e) {
		// e.printStackTrace();
		// }
	}
}
